//获取工程库清单
function getModelList() {
	/*var data = [
		{id:0, name:"调度运行模拟", image:"../images/model21.png", wizarIconNormal:"../images/model61_normal.png", wizarIconActive:"../images/model61_active.png", wizarImage:"../images/model31.png", title:"调度运行模拟", trait:"调度运行模拟"},
		{id:1, name:"电源规划", image:"../images/model22.png", wizarIconNormal:"../images/model62_normal.png", wizarIconActive:"../images/model62_active.png", wizarImage:"../images/model32.png", title:"电源规划", trait:"电源规划"},
		{id:2, name:"电网规划", image:"../images/model23.png", wizarIconNormal:"../images/model63_normal.png", wizarIconActive:"../images/model63_active.png", wizarImage:"../images/model33.png", title:"电网规划", trait:"电网规划"},
		{id:3, name:"负荷预测", image:"../images/model24.png", wizarIconNormal:"../images/model64_normal.png", wizarIconActive:"../images/model64_active.png", wizarImage:"../images/model34.png", title:"负荷预测", trait:"负荷预测"},
		{id:4, name:"风险评估", image:"../images/model25.png", wizarIconNormal:"../images/model65_normal.png", wizarIconActive:"../images/model65_active.png", wizarImage:"../images/model35.png", title:"风险评估", trait:"风险评估"}
	];
	//错误时返回{error:"查询工程库失败！"}*/
	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		url: "main/getModelList"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}
//获取工程清单
//userId:用户编号，modelId:功能模块编号，type=0：全部工程，type=1：个人工程，type=2：个人共享工程，type=3：所有共享工程，projectName：搜索文字
function getProjectList(userId, modelId, type, projectName) {
/*	var data = [
		{id:0, name:"工程XXXXXX1", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:1, name:"工程XXXXXX2", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:false},
		{id:2, name:"工程XXXXXX3", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:false},
		{id:3, name:"工程XXXXXX4", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:4, name:"工程XXXXXX5", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:false},
		{id:5, name:"工程XXXXXX6", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:6, name:"工程XXXXXX7", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:false},
		{id:7, name:"工程XXXXXX8", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:8, name:"工程XXXXXX9", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:false},
		{id:9, name:"工程XXXXXX10", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:10, name:"工程XXXXXX11", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true},
		{id:11, name:"工程XXXXXX12", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-02", isShared:false}
	];
	//错误时返回{error:"查询工程失败！"}
*/	var result = [];
	if(userId == null){
		userId = "1";
	}
	$.ajax({
		async: false,
		dataType: "json",
		data: {userId:1, modelId:modelId, type:type, projectName:projectName},
		url: "main/getProjectList"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}
//获取工程信息
//projectId:工程编号
function getProject(projectId) {
/*	var data = {id:0, name:"工程名工程名工程名工程名MMMMMM", modelId:0, modelName:"调度运行模拟", createTime:"2019-01-01", isShared:true};
	//错误时返回{error:"查询工程失败！"}
*/	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		data: {projectId:projectId},
		url: "main/getProjectModelById"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}
//获取方案清单
//projectId:工程编号
function getPlanList(projectId) {
	/*var data = [
		{id:0, name:"方案名方案名方案名方案名MMMMMM"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"},
		{id:1, name:"方案XXXXXX2"}
	];
	//错误时返回{error:"查询方案失败！"}
*/	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		data: {projectId:projectId},
		url: "main/getPlanListByProjectId"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}

//projectId:工程编号
function getPlanInfo(projectId,planId) {
	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		data: {projectId:projectId,planId:planId},
		url: "main/getPlanByPlanId"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}
//新建工程
//userId：用户编号，modelId：工程编号，projectName：工程名，projectDemo：工程描述，planName：方案名，planDemo：方案描述
function createProject(userId, modelId, projectName, projectDemo, planName, planDemo,modelProject) {
/*	var info = {id:2, info:"创建工程成功。",error:"工程名已经存在！", itemName:"projectName"};
	//调用后台接口，传入参数，创建工程，返回执行信息
*/	var defer = $.Deferred();
	$.ajax({
		//async: false,
		dataType: "json",
		data: {userId:"1", modelId:modelId, projectName:projectName, projectDemo:projectDemo, planName:planName, planDemo:planDemo,projectOld:modelProject},
		url: "main/createProjectModel"
	}).done(function(res) {
		defer.resolve(eval("("+res.result+")"));
	});
	return defer.promise();
}

//修改工程
//userId：用户编号，modelId：工程编号，projectName：工程名，projectDemo：工程描述，planName：方案名，planDemo：方案描述
function editProject(projectId, projectName, projectDemo) {
/*	var info = {id:2, info:"创建工程成功。",error:"工程名已经存在！", itemName:"projectName"};
	//调用后台接口，传入参数，创建工程，返回执行信息
*/	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		data: {projectId:projectId, projectName:projectName, projectDemo:projectDemo},
		url: "main/editProject"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}

//新建方案
//projectId：工程编号，planName：方案名，planDemo：方案描述，inCopyPlanDemo：复制方案
function createPlan(projectId,modelId, planName, planDemo, copyPlanDemo) {
/*	var info = {id:2,info:"创建方案成功。",error:"新建方案失败！"};
	//调用后台接口，传入参数，创建方案，返回执行信息
*/	var defer = $.Deferred();
	$.ajax({
		//async: false,
		dataType: "json",
		data: {projectId:projectId,modelId:modelId, planName:planName, planDemo:planDemo, copyPlanDemo:copyPlanDemo},
		url: "main/createPlan"
	}).done(function(res) {
		defer.resolve(eval("("+res.result+")"));
	});
	return defer.promise();
}

//修改方案
//planId：方案编号，planName：方案名，planDemo：方案描述
function editPlan(projectId, planName, planDemo) {
/*	var info = {id:2,info:"创建方案成功。",error:"新建方案失败！"};
	//调用后台接口，传入参数，创建方案，返回执行信息
*/	var result = [];
	$.ajax({
		async: false,
		dataType: "json",
		data: {planId:planId, planName:planName, planDemo:planDemo},
		url: "main/editPlan"
	}).done(function(res) {
		result = eval("("+res.result+")");
	});
	return result;
}


//删除方案
//planId：方案编号，planName：方案名，planDemo：方案描述
function delPlan(projectId, planName, planDemo) {
/*	var info = {id:2,info:"创建方案成功。",error:"新建方案失败！"};
	//调用后台接口，传入参数，创建方案，返回执行信息
*/	var defer = $.Deferred();
	$.ajax({
		//async: false,
		dataType: "json",
		data: {planId:planId},
		url: "main/deletePlan"
	}).done(function(res) {
		defer.resolve(eval("("+res.result+")"));
	});
	return defer.promise();
}



